package org.bmind.datasword.config.dto;

import java.util.ArrayList;
import java.util.Collection;

import org.bmind.datasword.utils.EqualsUtil;
import org.bmind.datasword.utils.HashCodeUtil;
import org.bmind.datasword.utils.StorageUtilities;

/**
 * 
 * @author valerio
 *
 */
public class DConfigFunctionParameters {
	static { StorageUtilities.addREngineType(DConfigFunctionParameters.class); }

	private int fHashCode;
	private int min = 0;
	private int max = 0;
	private int id = 0;
	private int def = 0;
	
	private String label = null;
	private String hint = null;
	private String parName = null;
	private DDataType dataType = null;
	private Boolean writable = true;
		
	private Collection<String> admValue = new ArrayList<String>();
	
	
	public DConfigFunctionParameters() {}

	/**
	 * @return the min
	 */
	public int getMin() {return min;}
	public void setMin(int min) {this.min = min;}

	/**
	 * @return the max
	 */
	public int getMax() {return max;}
	public void setMax(int max) {this.max = max;}

	/**
	 * @return the label
	 */
	public String getLabel() {return label;}
	public void setLabel(String label) {this.label = label;}

	/**
	 * @return the hint
	 */
	public String getHint() {return hint;}
	public void setHint(String hint) {this.hint = hint;}

	/**
	 * @return the name
	 */
	public String getParName() {return parName;}
	public void setParName(String name) {this.parName = name;}

	/**
	 * @return the id
	 */
	public int getId() {return id;}
	public void setId(int id) {this.id = id;}

	/**
	 * @return the def
	 */
	public int getDef() {return def;}
	public void setDef(int def) {this.def = def;}

	/**
	 * @return the admValue
	 */
	public Collection<String> getAdmValue() {return admValue;}
	public void setAdmValue(Collection<String> admValue) {this.admValue = admValue;}

	/**
	 * @return the dataType
	 */
	public DDataType getDataType() {return dataType;}
	public void setDataType(DDataType dataType) {this.dataType = dataType;}
	
	/**
     * @return the writable
     */
    public Boolean getWritable() {return writable; }
    public void setWritable(Boolean writable) {this.writable = writable;}

	/* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	   
  	  if ( this == obj ) return true;

	    if ( !(obj instanceof DConfigFunctionParameters) ) return false;
	    	DConfigFunctionParameters dFP = (DConfigFunctionParameters)obj;
    	
    	return	EqualsUtil.areEqual(this.parName, dFP.parName) &&
    			EqualsUtil.areEqual(this.dataType, dFP.dataType) &&
    			EqualsUtil.areEqual(this.label, dFP.label) &&
    			EqualsUtil.areEqual(this.min, dFP.min) &&
    			EqualsUtil.areEqual(this.max, dFP.max) &&
    			EqualsUtil.areEqual(this.def, dFP.def)&&
    			EqualsUtil.areEqual(this.writable, dFP.writable)&&
    			EqualsUtil.areEqual(this.id, dFP.id)&&
    			EqualsUtil.areEqual(this.hint, dFP.hint)&&
    			EqualsUtil.areEqual(this.admValue, dFP.admValue);
	    
    }

    
   
	/* (non-Javadoc)
     * @see org.bmind.datasword.config.dto.DObjCommon#hashCode()
     */
	@Override
	public int hashCode() {
		
		// this style of lazy initialization is
		// suitable only if the object is immutable
		if (fHashCode == 0) {
		int result = HashCodeUtil.SEED;
			result = HashCodeUtil.hash(result, getId());
			result = HashCodeUtil.hash(result, getDef());
			result = HashCodeUtil.hash(result, getMax());
			result = HashCodeUtil.hash(result, getMin());
			result = HashCodeUtil.hash(result, getAdmValue());
			result = HashCodeUtil.hash(result, getDataType());
			result = HashCodeUtil.hash(result, getHint());
			result = HashCodeUtil.hash(result, getLabel());
			result = HashCodeUtil.hash(result, getParName());
			result = HashCodeUtil.hash(result, getWritable());
			fHashCode = result;
		}
		return fHashCode;
	}
	
	
	
}
